home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-07-23 | 1.3 KB | 93 lines | [TEXT/MPS ] |
- //
- // © Copyright 1990 Apple Computer, Inc. By Ricardo Batista
- //
-
- #include "Types.h"
- #include "Memory.h"
- #include "Menus.h"
- #include "Packages.h"
- #include "HyperXCMD.h"
-
-
- void GetHShort(Handle H, short *s);
- Handle SetHLong(long num);
- void GetHString(Handle H, char *s);
-
- pascal void MAIN(XCmdPtr xcmd)
- {
- char title[256];
- short id;
- long num;
-
- if (xcmd->paramCount != 2)
- return;
- GetHShort(xcmd->params[0], &id);
- GetHString(xcmd->params[1], title);
- num = (long) NewMenu(id, title);
- xcmd->returnValue = SetHLong(num);
- }
-
-
- void GetHShort(Handle H, short *s)
- {
- short len;
- char st[256];
- long num;
-
- *s = 0;
- HLock(H);
- len = (short) GetHandleSize(H);
- if (len > 255)
- len = 255;
- BlockMove(*H, &st[1], (long) len);
- HUnlock(H);
- len = 1;
- while (st[len])
- len++;
- st[0] = len - 1;
- StringToNum(st, &num);
- *s = (short) num;
- }
-
-
-
- Handle SetHLong(long num)
- {
- Handle H;
- char st[60];
- short len;
-
- NumToString(num, st);
- len = st[0];
- H = NewHandle((long) len);
- if (H) {
- HLock(H);
- BlockMove(&st[1], *H, (long) len);
- (*H)[len] = 0;
- }
- return(H);
- }
-
-
-
-
-
-
-
- void GetHString(Handle H, char *s)
- {
- short len;
- char st[256];
-
- HLock(H);
- len = (short) GetHandleSize(H);
- if (len > 255)
- len = 255;
- BlockMove(*H, &st[1], (long) len);
- HUnlock(H);
- len = 1;
- while (st[len])
- len++;
- st[0] = len - 1;
- BlockMove(st, s, (long) len);
- }